package com.zcy.handler;

import com.rabbitmq.client.Channel;
import com.zcy.config.RabbitmqConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class ReceiveHandler {
    //监听email队列
    @RabbitListener(queues = {RabbitmqConfig.QUEUE_INFORM_EMAIL})
    public void receive_email(String msg, Message message, Channel channel) throws IOException {
        System.out.println("email队列消费消息："+msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

    //监听sms队列
    @RabbitListener(queues = {RabbitmqConfig.QUEUE_INFORM_SMS})
    public void receive_sms(String msg, Message message, Channel channel) throws IOException {
        System.out.println("sms队列消费消息："+msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
} 
